package com.maila.calltaxi_driver.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.maila.calltaxi_driver.R;
import com.maila.calltaxi_driver.data.Order;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by Administrator on 2017/6/30.
 */

public class HallOrderAdapter extends BaseAdapter {
    Context context;
    List<Order> datas;
    public HallOrderAdapter(Context context) {
        this.context = context;
        datas=new ArrayList<>();
    }

    public List<Order> getDatas() {
        return datas;
    }

    public void setDatas(List<Order> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    public void addDatas(List<Order> datas) {
        this.datas .addAll(datas);
        notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_hall_order, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
            AutoUtils.autoSize(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.orderPosition.setText(datas.get(position).getPositions());
        holder.orderStatus.setText(datas.get(position).getStatus());
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.order_position)
        TextView orderPosition;
        @BindView(R.id.order_status)
        TextView orderStatus;
        @BindView(R.id.ll_goto_details)
        AutoLinearLayout llGotoDetails;
        @BindView(R.id.btn_take_order)
        ImageView btnTakeOrder;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
